﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
using System.Security.Cryptography;

namespace BTN04.DAO
{
    public class DataProvider
    {
        public static string ConnectionString
        {
            get 
            { 
                return ConfigurationManager.ConnectionStrings["cnnDongHoShop"].ConnectionString;
                //return @"Data Source=TRUNGCUONG-PC\SQLEXPRESS;Initial Catalog=DongHoShop;Integrated Security=True";
                //return @"Data Source=TRUNGCUONG-PC\SQLEXPRESS;Initial Catalog=DongHoShop;Integrated Security=True";
            }
        }
        public static byte[] encryptData(string data)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider md5Hasher = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] hashedBytes;
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
            hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(data));
            return hashedBytes;
        }
        public static string Md5AddSecret(string strChange)
        {
            //Change the syllable into UTF8 code
            byte[] pass = Encoding.Default.GetBytes(strChange);

            MD5 md5 = new MD5CryptoServiceProvider();

            string strPassword = Encoding.Default.GetString(md5.ComputeHash(pass));
            return strPassword;
        }

    }
}
